const { Controller } = require('egg');
const { ctxBodyFormatter } = require('../util/formatter');

class ExperimentTotalScoreController extends Controller {
  async index() {
    const { ctx, service } = this;
    const res = ctxBodyFormatter(await service.experimentTotalScore.getAllExperimentTotalScore());
    ctx.status = res.status;
    ctx.body = res.body;
  }

  async show() {
    const { ctx, service } = this;
    const experimentTotalScore = ctx.params;
    const res = ctxBodyFormatter(await service.experimentTotalScore.getExperimentTotalScore(experimentTotalScore));
    ctx.status = res.status;
    ctx.body = res.body;
  }

  async create() {
    const { ctx, service } = this;
    const experimentTotalScore = ctx.request.body;
    const res = ctxBodyFormatter(await service.experimentTotalScore.appendExperimentTotalScore(experimentTotalScore));
    ctx.status = res.status;
    ctx.body = res.body;
  }

  async update() {
    const { ctx, service } = this;
    const experimentTotalScore = ctx.request.body;
    const res = ctxBodyFormatter(await service.experimentTotalScore.updateExperimentTotalScore(experimentTotalScore));
    ctx.status = res.status;
    ctx.body = res.body;
  }

  async destroy() {
    const { ctx, service } = this;
    const experimentTotalScore = ctx.params;
    const res = ctxBodyFormatter(await service.experimentTotalScore.destroyExperimentTotalScore(experimentTotalScore));
    ctx.status = res.status;
    ctx.body = res.body;
  }
}

module.exports = ExperimentTotalScoreController;
